/*
 * File:   Command.h
 * Author: Muhammad Anis
 */

#include "../Utilities/boolean.h"
#include "../ADTCalendar/Calendar.h"
#include "../ADTCSString/CSString.h"

#ifndef COMMAND_H
#define	COMMAND_H

#define MAX_COMMAND 100
/**
 * Structure of a Command, contains a name and pointer to function
 */
typedef struct {
    char* name; // instruction name
    void (*instruction)(Calendar *c,char** argv); // pointer to executed function
} Command;


/**
 * Make command with given name and instruction
 * @param name Name of Command
 * @param instruction Instruction mapped with name
 * @return Command with name=name and instruction=instruction
 */
Command MakeCommand(char* name, void (*instruction)(Calendar *cal,char** argv));

/**
 * Add command to array with constraint that array is not full
 * @param c
 */
void AddInstruction(Command c);

/**
 * Execute an instruction with given name
 * @param name name of instruction
 * @param argv instruction's parameter
 */
void Execute(char* name,Calendar *c,char** argv);

/**
 * Remove a command in array (if exists)
 * Not Implemented Yet
 * @param name name of command
 */
void RemoveCommand(char* name);

/**
 * Check if a command with specified name already exist
 * @param name name of command
 * @return true if there is a command with name=name
 */
int isCommandExist(char* name);

/**
 * Procedure for Testing purpose
 * @param argv
 */
void Print(Calendar *c,char** argv);
#endif	/* COMMAND_H */

